package com.example.chapter3_1.dao;

import com.example.chapter3_1.entity.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserDao {

    @Results(id = "userMap",value = {
            @Result(id = true,property = "name",column = "name"),
            @Result(property = "password",column = "password"),
            @Result(property = "sex",column = "sex"),
            @Result(property = "id",column = "id"),
    })
    @Select("select * from user where name = #{userName} ")
    User getUserByName(@Param("userName") String name);

    @Select("select count(1) from user where name = #{name}")
    int findUserByName(String name);

    @Insert("insert into user(name,password,sex) values (#{name},#{password},#{sex})")
    int creatUser(User user);
}
